package com.mvp.shq.washer.adapter;

import android.content.Context;
import android.support.v4.content.ContextCompat;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.mvp.shq.washer.R;
import com.mvp.shq.washer.entity.ShopSortType;

import java.util.List;

/**
 * Created by shq1 on 2017/10/9.
 */

public class SpinnerAdapter extends BaseAdapter {
    private Context context;
    private List<ShopSortType> mDataList;
    public SpinnerAdapter(Context mContext,List<ShopSortType> list){
        context = mContext;
        mDataList = list;
    }

    @Override
    public int getCount() {
        return mDataList.size();
    }

    @Override
    public Object getItem(int position) {
        return mDataList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = View.inflate(context, R.layout.spinner_item, null);
        TextView textView = (TextView) convertView.findViewById(R.id.item_main_tv);
        textView.setText(mDataList.get(position).getName());
        if (mDataList.get(position).isChoose()){
            textView.setTextColor(ContextCompat.getColor(context,R.color.money));
        }else {
            textView.setTextColor(ContextCompat.getColor(context,R.color.shop_text_black));
        }
        return convertView;
    }
}
